﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpLearn_Chapter4.Class
{
    /// <summary>
    /// 在Class命名空间中自定义的Person类
    /// </summary>
    public class Person
    {
        //类成员
        public  string? Name { get; set; }    //  自动属性
        public int Age { get; set; }

        /// <summary>
        /// run方法
        /// </summary>
        /// <param name="speed">run的速度</param>
        public void Run(float speed)
        {

        }

        //构造函数
        /// <summary>
        /// 使用姓名和年龄对Person初始化
        /// </summary>
        /// <param name="name">姓名</param>
        /// <param name="age">年龄</param>
        public Person(string name,int age)
        {
            Name = name;
            Age = age;
        }

        //静态成员
        /// <summary>
        /// 所在的学院
        /// </summary>
        public static string? SchoolName;

    }

    /// <summary>
    /// 类的继承：
    /// Student：子类/派生类
    /// Person：父类/基类
    /// </summary>
    public class Student : Person
    {
        public string StudentId { get; set; }
        public Student(string name,int age,string studentid) : base(name, age)
        {
            StudentId = studentid;
        }
    }
    /// <summary>
    /// 抽象类
    /// </summary>
    public abstract  class Shape
    {
        /// <summary>
        /// 抽象方法,未实现
        /// </summary>
        /// <returns>计算Shape面积</returns>
        public abstract double Area();

        public int abs(int x)
        {
            return Math.Abs(x);
        }
    }
    /// <summary>
    /// Square继承Shape
    /// </summary>
    public class Square : Shape
    {
        public double length { get; set; }
        /// <summary>
        /// 实现父类抽象方法
        /// </summary>
        /// <returns></returns>
        public override double Area()
        {
            return length * length;
        }
    }

    //接口：约定、合同
    /// <summary>
    /// 定义一个接口
    /// </summary>
    interface IDrawable
    {
        void Draw();
    }


    public class Triangle :Shape, IDrawable
    {
        public override double Area()
        {
            throw new NotImplementedException();
        }

        public void Draw()
        {
            //throw new NotImplementedException();
        }
    }

    internal class ClassLearn
    {
        public void Test()
        {
            Person p1 = new Person("abc", 10);

            Shape s1 = new Square();

            //Square s2 = new Shape();
        }
    }
}
